<?php

namespace app\api\controller;

use app\services\LikeService;
use app\services\SearchService;
use support\Request;

class SearchController
{
    public function search(Request $request)
    {
        try {
            $page = $request->post('page', 1);
            $length = $request->post('length', 10);
            $keyword = $request->post('keyword');
            $type = $request->post('type', SearchService::TYPE_USER);

            $data = SearchService::search($keyword, $type, $page, $length);

            return ok_rsp('成功', $data);

        } catch (\Exception $e) {
            return err_rsp($e->getMessage());
        }
    }
}